package dao

import (
	"backend/app/dao/mysql"
	"backend/app/model"
)

func CheckRoleIsExist(rolename string) (bool, error) {
	return mysql.CheckRoleIsExist(rolename)
}
func QueryRoleByID(roleId int32) (*model.Role, error) {
	return mysql.QueryRoleByID(int64(roleId))
}

func SaveRole(role *model.Role) error {
	return mysql.InsertRole(role)
}

func CheckUserRoleIsExist(userRole *model.UserRole) (bool, error) {
	return mysql.CheckUserRoleIsExist(int64(userRole.RoleId), userRole.UserId)
}

func SaveUserRole(userRole *model.UserRole) error {
	return mysql.InsertUserRole(userRole)
}

func DeleteUserRole(userRole *model.UserRole) error {
	return mysql.DeleteUserRole(userRole.UserId, int64(userRole.RoleId))
}

func QueryUserRoles(userId int64) ([]*model.UserRole, error) {
	return mysql.QueryUserRolesByUserId(userId)
}
